#include "Program.h"


Program::Program(void) : Resource()
{
}


Program::~Program(void)
{
	Dispose();
}

int Program::GetUniformLocation(const char * name)
{
	return glGetUniformLocation(program,name);
}

void Program::Bind()
{
	glUseProgram(program);
}
void Program::Unbind()
{
	glUseProgram(0);
}
void Program::Dispose()
{
	Unbind();
	glDeleteProgram(program);
}

void Program::AttachShader(GLuint shader)
{
	if(IsAllocated() == false)
	{
		program = glCreateProgram();
		SetAllocated();
	}

	glAttachShader(program,shader);
}
void Program::LinkShaders()
{
	if(IsAllocated() == false)
	{
		program = glCreateProgram();
		SetAllocated();
	}

	glLinkProgram(program);
}
